package serverside;

public class ChangePIN extends Transaction {
    private Keypad keypad;
    private String tmp;
    public ChangePIN(int _cardID, DatabasePack.BankDatabase atmBankDatabase, Screen atmScreen, Keypad atmKeypad){
        super(_cardID, atmBankDatabase, atmScreen);
        keypad =atmKeypad;
    }
    @Override
    public void execute() {
        System.out.println("Transaction::ChangePIN");
        Screen screen = getScreen();
        DatabasePack.BankDatabase database = getBankDatabase();
        
        screen.sendDataToClient("You can change.");
        String result = database.Change_PIN(getCardID(),
                Integer.parseInt(tmp = keypad.getInput()));
        System.out.println("Transaction::ChangePIN client sent: " + 
                tmp);
        screen.sendDataToClient(result);
        System.out.println("Transaction::ChangePIN result: " + result +
                    "\n");                
    }
    
}
